<script setup lang="ts">
const el = ref(null)
const show = ref(false)
useIntersectionObserver(el, ([{ isIntersecting }]) => {
  if (isIntersecting)
    show.value = isIntersecting
})

const list = ref([
  {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-11.png',
  }, {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-12.png',
  }, {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-13.png',
  },
])
function onEnter(el: any, done: any) {
  el.style.opacity = 0
  const delay = el.dataset.index * 100
  const animation = 'fadeInRight 0.8s infinite'
  setTimeout(() => {
    el.style.transition = 'opacity 0.8s '
    el.style.opacity = 1
    el.style.animation = animation
    el.style['animation-iteration-count'] = 1
    done()
  }, delay)
}
</script>

<template>
  <div id="yghd" ref="el" class="yuangonghuodong">
    <div class="content">
      <Transition name="animate-zoomIn">
        <h1 v-show="show" class="line-center-title">
          员工活动
        </h1>
      </Transition>
      <div class="list">
        <transition-group @enter="onEnter">
          <img v-for="(item, index) in list" v-show="show" :key="index" class="img" :src="item.img" :data-index="index">
        </transition-group>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.yuangonghuodong {
  min-height: 600px;
  padding-top: 50px;
  padding-bottom: 80px;

  .img {
    width: 100%;
    height: 300px;
    object-fit: cover;
  }

  .line-center-title {
    font-family: PangMenZhengDaoBiaoTiTi;
    margin-bottom: 40px;
  }
}
</style>
